package com.fieldchain.ex.fa100.utils.string;

import android.widget.EditText;
import android.widget.TextView;

/**
 * Created by biyunlong
 * Email: 1225198434@qq.com
 * Data:  2018/9/27
 */
public class DoubleParse {
    public static double parse(TextView tv){
        String str=tv.getText().toString();
        if(str==null||str.length()==0){
            return 0.00;
        }else{
            return Double.parseDouble(str);
        }
    }
    public static double parse(String str){

        if(str==null||str.length()==0||(str.contains(".")&&str.split("\\.").length<2)){
            return 0.00;
        }else{
            return Double.parseDouble(str);
        }
    }
    public static double parse(EditText et){
        String str=et.getText().toString();
        if(str==null||str.length()==0){
            return 0.00;
        }else{
            return Double.parseDouble(str);
        }
    }
}
